package com.redsoil.house.widget.actionbar;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.redsoil.house.R;
import com.zhy.autolayout.AutoRelativeLayout;

/**
 * Created by weidingqiang on 2018/12/20.
 */

public class NewsTopBar extends AutoRelativeLayout implements View.OnClickListener{

    private TextView middle_topbar_name;

    private ImageView middle_topbar_img;

    private NewsTopBarImp newsTopBarImp;

    public void setNewsTopBarImp(NewsTopBarImp newsTopBarImp) {
        this.newsTopBarImp = newsTopBarImp;
    }

    public NewsTopBar(Context context) {
        super(context);
    }

    public NewsTopBar(Context context, AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater inflater = LayoutInflater.from(context);
        inflater.inflate(R.layout.news_topbar, this, true);

        middle_topbar_name = (TextView) this.findViewById(R.id.middle_topbar_name);
        middle_topbar_img = (ImageView) this.findViewById(R.id.middle_topbar_img);

        middle_topbar_name.setOnClickListener(this);
        middle_topbar_img.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if(newsTopBarImp == null) return;
        newsTopBarImp.middle();
    }

    public void setData(String label){
        middle_topbar_name.setText(label);
    }

    public String getTitleLabel(){
        return  middle_topbar_name.getText().toString();
    }
}
